package com.dsh.contrller;

import com.dsh.entity.User;
import com.dsh.server.UserService;
import com.dsh.server.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/apiUser")
public class UserController {

    @Autowired
    UserService userService;

    @GetMapping("getName/{userName}")
    public User getUser(@PathVariable String userName) {
        return userService.getUserByName(userName);
    }

    @GetMapping("/getAll")
    public List<User> getUser() {
        return userService.getAllUsers();
    }

    @GetMapping("/insertUserList")
    public void insertUserList() {
        userService.insertUserList();
    }

    @GetMapping("/findInAge")
    public List<User> findInAge() {
        return userService.findInAge();
    }


    @GetMapping("/delUser")
    public void delUser() {
        userService.delUser();
    }

    @GetMapping("/updateUserSex")
    public void updateUserSex() {
        userService.updateUserSex();
    }

}
